package cn.wolfcode.luowowo.service.impl;

import cn.wolfcode.luowowo.domain.Destination;
import cn.wolfcode.luowowo.domain.Region;
import cn.wolfcode.luowowo.query.DestinationQuery;
import cn.wolfcode.luowowo.repository.DestinationRepository;
import cn.wolfcode.luowowo.repository.RegionRepository;
import cn.wolfcode.luowowo.service.IDestinationService;
import cn.wolfcode.luowowo.service.IRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DestinationServiceImpl implements IDestinationService {
    @Autowired
    private DestinationRepository destinationRepository;
    @Autowired
    private IRegionService regionService;


    @Override
    public Destination get(String id) {
        return null;
    }

    @Override
    public Page<Destination> query(DestinationQuery qo) {
        return null;
    }


    //查询出全部的数据
    @Override
    public List<Destination> list() {
        List<Destination> list = destinationRepository.findAll();
        return list;
    }

    //通过范围id查询出目的地
    @Override
    public List<Destination> getDestByRegionId(String rid) {
        //通过区域id 获取到目的地的集合
        Region region = regionService.get(rid);
        List<String> refIds = region.getRefIds();
        List<Destination> destinations = destinationRepository.findByIdIn(refIds);

        return destinations;
    }

    @Override
    public List<Destination> getToasts(String parentId) {
        return null;
    }

    @Override
    public List<Destination> getDestByRegionIdForApi(String regionId) {
        return null;
    }

    @Override
    public Destination getByName(String keyword) {
        return null;
    }
}
